package com.fanben100.util;

import java.awt.Container;

import javax.swing.JDialog;
import javax.swing.JFrame;

import com.fanben100.gui.TerminalFrame;

public class DialogUtil {
	
	public static JFrame getModalFrame(JDialog dialog){
		Container container = dialog.getParent(), root = container;
		TerminalFrame frame = null;
		while (container != null) {
			root = container;
			container = container.getParent();
			if (container instanceof TerminalFrame) {
				break;
			}
		}
		if (root != null && root instanceof TerminalFrame) {
			frame = (TerminalFrame) root;
		}
		return frame;
	}
}
